package com.xiaoxing.gongqiju.mvp.ui.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.widget.CheckBox;
import android.widget.CompoundButton;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.xiaoxing.gongqiju.R;
import com.xiaoxing.gongqiju.mvp.ui.entity.LiaoCheng_GongQiJu_ChuKuCaoZuo;

import java.util.List;

//import me.jessyan.armscomponent.commonres.utils.GlideUtil;


public class LiaoCheng_GongQiJu_ChuKuCaoZuoAdapter extends BaseQuickAdapter<LiaoCheng_GongQiJu_ChuKuCaoZuo.DataBean, BaseViewHolder> {

    private Context mContext;
    private ILiaoCheng_GongQiJu_ChuKuCaoZuoAdapter iLiaoCheng_gongQiJu_chuKuCaoZuoAdapter;

    public LiaoCheng_GongQiJu_ChuKuCaoZuoAdapter(Context context, @Nullable List<LiaoCheng_GongQiJu_ChuKuCaoZuo.DataBean> data, ILiaoCheng_GongQiJu_ChuKuCaoZuoAdapter iLiaoCheng_gongQiJu_chuKuCaoZuoAdapter) {
        super(R.layout.item_liao_cheng__gong_qi_ju__chu_ku_cao_zuo, data);
        this.mContext = context;
        this.iLiaoCheng_gongQiJu_chuKuCaoZuoAdapter = iLiaoCheng_gongQiJu_chuKuCaoZuoAdapter;
    }

    @Override
    protected void convert(BaseViewHolder helper, LiaoCheng_GongQiJu_ChuKuCaoZuo.DataBean item) {
        //GlideUtil.loadImage(mContext,item.getImg(),helper.getView(R.id.img_head));
        helper.setText(R.id.tv_jie_shou_ren_xing_ming, "接收人姓名:" + item.getRecevieusername());
        helper.setText(R.id.tv_jie_shou_ren_dian_hua, "接收人电话:" + item.getReceiveusephone());
        helper.setText(R.id.tv_shen_qing_chu_ku_id, "申请出库id:" + item.getOpid());
        helper.setText(R.id.tv_shen_qing_chu_ku_shu_liang, "申请出库数量:" + item.getOutNum());
        helper.setText(R.id.tv_gong_ju_suo_zai_cang_wei, "工具所在仓位:" + item.getSpname());
        helper.setText(R.id.tv_gong_ju_suo_zai_cang_wei_id, "工具所在仓位id:" + item.getSpid());
        helper.setText(R.id.tv_shen_qing_ren_xing_ming, "申请人姓名:" + item.getApplyusername());
        helper.setText(R.id.tv_shen_he_ren_xing_ming, "审核人姓名:" + item.getCheckusername());
        helper.setText(R.id.tv_shen_he_jie_guo, "审核结果:" + item.getCheckresult());
        helper.setText(R.id.tv_gong_ju_ji_liang_dan_wei, "工具计量单位:" + item.getUnit());
        helper.setText(R.id.tv_gong_ju_ming_cheng, "工具名称:" + item.getMaterialtoolname());
        CheckBox cb = helper.getView(R.id.cb);
        if (item.isChecked()) {
            cb.setChecked(true);
        } else {
            cb.setChecked(false);
        }

        cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    item.setChecked(true);
                    iLiaoCheng_gongQiJu_chuKuCaoZuoAdapter.addData(item);
                } else {
                    item.setChecked(false);
                    iLiaoCheng_gongQiJu_chuKuCaoZuoAdapter.delData(item);
                }
            }
        });
    }

    public interface ILiaoCheng_GongQiJu_ChuKuCaoZuoAdapter {

        void addData(LiaoCheng_GongQiJu_ChuKuCaoZuo.DataBean item);

        void delData(LiaoCheng_GongQiJu_ChuKuCaoZuo.DataBean item);
    }

}
